package com.heima.bos.service;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.transaction.annotation.Transactional;

import com.heima.bos.dao.DaoInter;
import com.heima.bos.dao.impl.BaseDaoImpl;
import com.heima.bos.utils.PageBean;
@SuppressWarnings("all")
@Transactional
public abstract class BaseService<T>{
//	public abstract BaseDaoImpl<T> getDao();
	public abstract DaoInter<T> getDao();
	
	// 查询所有
	public List<T> findAll() {
		return this.getDao().findAll();
	}

	// 增加对象
	public void save(T entity) {
		this.getDao().save(entity);
	}

	// 更新对象
	public void update(T entity) {
		this.getDao().update(entity);
	}

	// 删除
	public void delete(T entity) {
		this.getDao().delete(entity);
	}

	// 根据Id查询对象
	public T findById(Serializable id) {
		return this.getDao().findById(id);
	}

	// 离线查询
	public List<T> findByCriteria(DetachedCriteria criteria) {
		return this.getDao().findByCriteria(criteria);
	}

	public List<T> findByNameQuery(String queryName, Object... orgs) {
		return this.getDao().findByNameQuery(queryName, orgs);
	}

	public void executeNameQuery(String queryName, Object... orgs) {
		this.getDao().executeNameQuery(queryName, orgs);
	}
	// 分页
	public void pageList(PageBean<T> pageBean) {
		this.getDao().pageList(pageBean);
	}
}
